package de.fhaugsburg.games.boardgames.connect4.strategy;

import de.fhaugsburg.games.boardgames.connect4.Aintelligence;
import de.fhaugsburg.games.boardgames.connect4.BinaryPiece;
import de.fhaugsburg.games.boardgames.connect4.Connect4Board;

import java.util.Random; 

public class RandomRobot implements Aintelligence {

	
	/*
	 * (non-Javadoc)
	 * @see de.fhaugsburg.games.boardgames.connect4.Aintelligence#columnProposal(de.fhaugsburg.games.boardgames.Piece, de.fhaugsburg.games.boardgames.Board)
	 */
	public int columnProposal(BinaryPiece piece, Connect4Board board) {
		
		// start random number generator
		Random generator = new Random();
		int iRandColumn = 0;
		
		// generate random number until it fits in the board
		// FIXME: may loop infinitely
		do {
			iRandColumn = generator.nextInt(board.getWidth());
		}
		while (!board.isMoveValid(iRandColumn));
		
		return iRandColumn;
			
	}
}